package com.singfan.core.dao.database.impl;

import com.singfan.common.db.DaoBaseGeneric;
import com.singfan.core.dao.database.IJpushInfoDao;
import com.singfan.core.dao.database.model.JpushInfo;
import org.springframework.stereotype.Repository;

/**
 * Author: hansonghe
 * Date: 2015-09-08 16:06
 * Desc:
 */
@Repository
public class JpushInfoDaoImpl extends DaoBaseGeneric<JpushInfo> implements IJpushInfoDao  {
    @Override
    protected String getTableName(Object hashKey) {
        return tableNameBase;
    }

    @Override
    protected String getDatabaseId(Object hashKey) {
        return "app_1";
    }

    @Override
    public void insertOrUpdate(JpushInfo jpushInfo) {
        replace(null, jpushInfo);
    }

    @Override
    public JpushInfo selectByUserId(long userId) {
        String sql = "SELECT * FROM " + getTableName(null) + " WHERE user_id=?";
        return selectOne(null, sql, userId);
    }
}
